// pages/sita/prompts/prompts.js
var canvas_width = 0;
var canvas_height = 0
var canvas = null
const app = getApp()
var resolvePrivacyAuthorization
const CONTEXT = require('../../../utils/public_var.js')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    menuEntries: [],
    imgType: CONTEXT.TEXT_PAGE_TYPE,
    showPrivacy: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

    /** this.setData({
        // menuEntries:res.data.dataItem
     */



     this.getMenu()
//    this.setData({
//      menuEntries:
// [
//   {
//   "menuID": "101",
//   "menuName": "排忧解难(免费)",
//   "welcomeIntro": "主公万安，在下10年寒窗，博古通今，通晓文理。请主公示下",
//   "iconAddr":"https://genious.sitacloud.com/icon_imagee/101.svg",
//   "funCallURI":"https://genious.sitacloud.com/free_chat",
//   "isFree":true,
//   "promptString": "Enter your choice for Profile:",
//   "funcSupport":  {
//       "textInput": {
//         "available":"1",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/textInput.svg",
//         "iconName":"主公，请吩咐"
//       },
//       "imageOCR": {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageOCR.svg",
//         "iconName":"文字识别"
//       },
//       "voiceInput":{
//       "available":"1",
//       "iconAddr":"https://genious.sitacloud.com/icon_imagee/voiceInput.svg",
//       "iconName":"语音输入"
//       },
//       "fileupload": {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/fileupload.svg",
//         "iconName":"文件"
//       },
//       "soundupload":  {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/soundupload.svg",
//         "iconName":"声音分析"
//       },
//       "imageupload": {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageupload.svg",
//         "iconName":"图片处理"
//       }
    
//     }
//   },
//   {
//       "menuID": "102",
//       "menuName": "翻译",
//       "welcomeIntro": "主公万安，在下可识别图片中文字，还可翻译各国语言，字迹区域精准。如需翻译，识别文字后请指示我翻译何种语言",
//       "iconAddr":"https://genious.sitacloud.com/icon_imagee/101.svg",
//       // "funCallURI":"https://genious.sitacloud.com/question_search",
//       "isFree":false,
//       "promptString": "Enter your choice for Profile:",
//       "hints":{
//         "title":"拍图参考",
//         "subtitle":"根据示例上传清晰图片",
//         "imgList":["https://genious.sitacloud.com/icon_imagee/textInput.svg",
//                    "https://genious.sitacloud.com/icon_imagee/textInput.svg",
//                    "https://genious.sitacloud.com/icon_imagee/textInput.svg",
//                    "https://genious.sitacloud.com/icon_imagee/textInput.svg"]
//               },
//       "funcSupport":  {
//          "textInput": {
//             "available":"1",
//             "iconAddr":"https://genious.sitacloud.com/icon_imagee/textInput.svg",
//             "iconName":"主公，请明示在下做什么"
//           },
//           "imageOCR": {
//             "available":"1",
//             "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageOCR.svg",
//             "iconName":"文字识别"
//           },
//           "voiceInput":{
//             "available":"0",
//             "iconAddr":"https://genious.sitacloud.com/icon_imagee/voiceInput.svg",
//             "iconName":"语音输入"
//           },
//           "fileupload": {
//             "available":"0",
//             "iconAddr":"https://genious.sitacloud.com/icon_imagee/fileupload.svg",
//             "iconName":"文件"
//           },
//           "soundupload":  {
//             "available":"0",
//             "iconAddr":"https://genious.sitacloud.com/icon_imagee/soundupload.svg",
//             "iconName":"声音分析"
//           },
//           "imageupload": {
//             "available":"0",
//             "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageupload.svg",
//             "iconName":"图片处理"
//           }
      
        
//       }
//   },
//   {
//     "menuID": "103",
//     "menuName": "图文",
//     "welcomeIntro": "主公万安，您最近绞尽脑汁，灵感枯竭，让在下为您构思创意，挖掘需求，出谋划策如何",
//     "iconAddr":"https://genious.sitacloud.com/icon_imagee/ideas.svg",
//     "funCallURI":"https://genious.sitacloud.com/v2question_search",
//       "isFree":false,
//     "promptString": "Enter your choice for Profile:",
//     "funcSupport":  {
//       "textInput": {
//           "available":"1",
//           "iconAddr":"https://genious.sitacloud.com/icon_imagee/textInput.svg",
//           "iconName":"主公，请吩咐"
//         },
//       "imageOCR": {
//           "available":"0",
//           "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageOCR.svg",
//           "iconName":"文字识别"
//         },
//       "voiceInput":{
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/voiceInput.svg",
//         "iconName":"语音输入"
//       },
//       "fileupload": {
//         "available":"1",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/fileupload.svg",
//         "iconName":"文件"
//       },
//       "soundupload":  {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/soundupload.svg",
//         "iconName":"声音分析"
//       },
//       "imageupload": {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageupload.svg",
//         "iconName":"图片处理"
//       }     
//     }
//   },
//   {
//     "menuID": "104",
//     "menuName": "数学",
//     "welcomeIntro": "主公万安，在下精通数理化，博古通今，有何难题尽管吩咐",
//     "iconAddr":"https://genious.sitacloud.com/icon_imagee/102.svg",
//     "funCallURI":"https://genious.sitacloud.com/mathocr_search",
//       "isFree":false,
//     "promptString": "Enter your choice for Profile:",
//     "funcSupport":  {
//       "textInput": {
//           "available":"0",
//           "iconAddr":"https://genious.sitacloud.com/icon_imagee/textInput.svg",
//           "iconName":"主公，请吩咐"
//         },
//       "imageOCR": {
//           "available":"0",
//           "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageOCR.svg",
//           "iconName":"文字识别"
//         },
//       "voiceInput":{
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/voiceInput.svg",
//         "iconName":"语音输入"
//       },
//       "fileupload": {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/fileupload.svg",
//         "iconName":"文件"
//       },
//       "soundupload":  {
//         "available":"0",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/soundupload.svg",
//         "iconName":"声音分析"
//       },
//       "imageupload": {
//         "available":"1",
//         "iconAddr":"https://genious.sitacloud.com/icon_imagee/imageupload.svg",
//         "iconName":"图片处理"
//       }
    
      
//     }
//   },
 
// ]
//    })
  },
  getMenu() {
    var that = this
    wx.request({
      url: app.app_url.BASE_URL + app.app_url.LOGIN_CHECK,
      method: "POST",
      success(res) {
        if (res.data.statusCode == 200) {
          console.log(res)
          that.setData({
            menuEntries: res.data.dataItem
          })
          app.saveTabItem(res.data.dataItem)

        } else {
          console.log(app.getTabItem())
          that.setData({
            menuEntries: app.getTabItem()
          })

        }

      },
      fail(res) {

        console.log(app.getTabItem())
        that.setData({
          menuEntries: app.getTabItem()
        })

      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

    wx.onNeedPrivacyAuthorization(resolve => {
      // 需要用户同意隐私授权时
      // 弹出开发者自定义的隐私授权弹窗
      console.log(resolve)
      this.setData({
        showPrivacy: true
      })
      resolvePrivacyAuthorization = resolve
    })

  },
  disaGreePrivacy() {
    resolvePrivacyAuthorization({
      event: 'disagree'
    })
  },
  handleAgreePrivacyAuthorization() {
    // 用户点击同意按钮后
    resolvePrivacyAuthorization({
      buttonId: 'agree-btn',
      event: 'agree'
    })
    // 用户点击同意后，开发者调用 resolve({ buttonId: 'agree-btn', event: 'agree' })  告知平台用户已经同意，参数传同意按钮的id。为确保用户有同意的操作，基础库在 resolve 被调用后，会去检查对应的同意按钮有没有被点击过。检查通过后，相关隐私接口会继续调用
    // 用户点击拒绝后，开发者调用 resolve({ event:'disagree' }) 告知平台用户已经拒绝
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  itemClick(res) {
    let item = res.currentTarget.dataset.item
    var dataJson = JSON.stringify(item)

    if (item.SubMenu == undefined) {
      wx.navigateTo({
        url: '../chat/chat?itemdata=' + dataJson
      })
    } else {


      wx.navigateTo({
        url: '../subItem/subItem?itemData=' + dataJson,
      })
    }





  }

})